package net.loyin.app.ctrl.front;

import com.jfinal.plugin.ehcache.CacheName;
import net.loyin.annotation.ControllerBind;
import net.loyin.app.model.Article;
import net.loyin.app.model.ArticleCate;
import org.apache.commons.lang.StringUtils;

/**
 * Created by loyin on 16/1/12.
 */
@ControllerBind(route = "/article")
public class ArticleCtrl extends FrontBaseCtrl{
    @CacheName("1day")
    public void view(){
        String id=this.getPara(0);
        this.setAttr("po", Article.dao.qryById(id));
    }
    /**设置文章阅读次数*/
    public void readCount(){
        String id=this.getPara(0);
        if(StringUtils.isNotBlank(id)){
            Article.dao.updateReadCount(id);
        }
        renderNull();
    }
    /**类别显示*/
    public void cateList(){
        String cate_id=this.getPara(0);
        String article_id=this.getPara(1);
        if(StringUtils.isNotBlank(article_id)){
            this.setAttr("po", Article.dao.qryById(article_id));
        }
    }
    /**单独显示类别中的文章*/
    public void cateView(){
        String id=this.getPara(0);
        this.setAttr("po", Article.dao.qryById(id));
    }
}
